<template>
  <div style="flex:1;font-size: 18px;line-height: 60px;display: flex">
    <div style="flex:1; font-size: 20px">
      <span :class="collapseBtnClass" style="cursor:pointer" @click="collapse"></span>
    </div>

    <el-dropdown style="width: 100px">
      <div style="display: inline-block">
        <img :src="user.logoUrl" alt=""
             style="width: 30px; border-radius: 50%; position: relative; top: 10px; right: 5px">
        <span >{{ user.realName }}</span>
      </div>
      <i class="el-icon-arrow-down" style="margin-left: 5px"></i>
      <el-dropdown-menu slot="dropdown" style="width:100px;text-align: center">

        <el-dropdown-item style="font-size: 14px;padding: 5px 0" >个人中心</el-dropdown-item>
        <el-dropdown-item>
          <span @click="LogOut" style="font-size: 14px;padding: 5px 0">退出</span>
        </el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  name: "Header",
  props: {
    collapseBtnClass:String,
    collapse:Function
  },
  data(){
    return{
      user:localStorage.getItem("userDto")?JSON.parse(localStorage.getItem("userDto")):{ realName:"请登录" }
    }
    },
  methods:{
    LogOut(){
      this.$router.push("/")
      localStorage.removeItem("userDto")
      this.$message.success("退出成功！")
    }
  }
}
</script>

<style scoped>

</style>